
#include "conf.h"
#include "common.h"
#include "log.h"
#include "lua_api.h"
#include "globals.h"

void parse_conf(void)
{
	parse_lua_conf(conf->log.conf);
}


void config_default(void)
{
	/* default value of config->log */
	if(!conf) {
		conf = mempool_alloc(sizeof(*conf));
		assert(conf);
	}

	conf->log.error = strdup(DEFAULT_ERROR_LOG);
	conf->log.debug = strdup(DEFAULT_DEBUG_LOG);
	conf->log.warn = strdup(DEFAULT_WARN_LOG);
	conf->log.access = strdup(DEFAULT_ACCESS_LOG);

	conf->server.port = htons(DEFAULT_PORT);
	inet_pton(AF_INET, DEFAULT_BIND_ADDR4, &conf->server.bind_addr4);
	conf->server.debug_mode = DEFAULT_DEBUG_MODE;
	conf->server.debug_level = DEFAULT_DEBUG_LEVEL;
	conf->server.worker = DEFAULT_WORKER_NUMBER;
	conf->server.max_size_in_mem = DEFAULT_MAX_SIZE_IN_MEM;
	conf->server.max_size_in_shm = DEFAULT_MAX_SIZE_IN_SHM;
	conf->server.objects = DEFAULT_OBJECTS;
	conf->server.max_object_size_in_mem = DEFAULT_MAX_OBJECT_SIZE_IN_MEM;
	
	conf->timeout.client_life = DEFAULT_CLIENT_LIFE;
	conf->timeout.server_life = DEFAULT_SERVER_LIFE;
	conf->timeout.request = DEFAULT_REQUEST_TIMEOUT;
	conf->timeout.reply = DEFAULT_REPLY_TIMEOUT;
	conf->timeout.connect = DEFAULT_CONNECT_TIMEOUT;

	if(!conf->cache_dir)
		conf->cache_dir = array_create();
}
